package com.base.commonlib.base;

import android.support.annotation.CallSuper;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.base.commonlib.R;


/**
 * Date：2019/4/11 上午9:55
 * Creator：arvin
 * Des：
 */

public abstract class CBaseBarActivity extends CBaseActivity {
    private ImageView mImg;
    private Toolbar mToolbar;
    private TextView mTitle;
    @CallSuper
    @Override
    protected void init() {
        mTitle = findViewById(R.id.title);
        mToolbar = findViewById(R.id.bar);
        mImg = findViewById(R.id.img_right);
        mToolbar.setTitle("");
        setSupportActionBar(mToolbar);
    }
    protected void setBarTitle(String tittle)
    {
        mTitle.setText(tittle);

    }
    protected void setRigImg(int mResource, View.OnClickListener v){
        if (mImg != null){
            mImg.setBackgroundResource(mResource);
            mImg.setVisibility(View.VISIBLE);
            mImg.setOnClickListener(v);
        }
    }

    protected void setBackNavigation()
    {
        mToolbar.setNavigationIcon(R.drawable.ic_title_back);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
